<!DOCTYPE HTML>
<!--
	Dimension by HTML5 UP
	html5up.net | @ajlkn
	Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
 <head>
  <title>
   Dimension by HTML5 UP
  </title>
  <!-- <meta charset="utf-8" /> -->
  <!-- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> -->
  <meta charset="utf-8"/>
  <meta content="width=device-width,initial-scale=1.0" name="viewport"/>
  <link href="../../assets/css/article.css" rel="stylesheet"/>
  <link href="https://cdn.bootcss.com/highlight.js/9.15.8/styles/github.min.css" rel="stylesheet"/>
  <noscript>
   <link href="../../assets/css/noscript.css" rel="stylesheet"/>
  </noscript>
 </head>
 <body>
  <div id="app">
  </div>
  <!-- built files will be auto injected -->
 </body>
 <body class="is-preload">
  <!-- Wrapper -->
  <div id="wrapper">
   <!-- Main -->
   <div id="main">
    <article id="article">
     <h1 id="nginx">
      Nginx负载均衡
     </h1>
     <hr/>
     <h2 id="_1">
      配置
     </h2>
     <p>
      首先需要配置定义一个server组:backend,用来表示所有存在的后台服务，然后将所有的流量重定向到http://backend,将这个Nginx示例上的所有流量重定向到定义的backend上，大致内容如下：
     </p>
     <div class="codehilite">
      <pre><span></span><code>http <span class="o">{</span>
    upstream backend <span class="o">{</span>
        server backend1.example.com<span class="p">;</span>
        server backend2.example.com<span class="p">;</span>
        server <span class="m">192</span>.0.0.1 backup<span class="p">;</span>
    <span class="o">}</span>

    server <span class="o">{</span>
        location / <span class="o">{</span>
            proxy_pass http://backend<span class="p">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">}</span>
</code></pre>
     </div>
     <p>
      其中还有很多的细节，比如权重和负载均衡算法，下面的参考链接中已有详细的说明，自行点击查看。
     </p>
     <h2 id="_2">
      参考链接
     </h2>
     <ul>
      <li>
       <a href="https://juejin.im/post/5bbb84ca5188255c393f8473">
        NGINX 负载均衡
       </a>
      </li>
      <li>
       <a href="https://blog.csdn.net/m0_37529303/article/details/77822633">
        Nginx配置文件实例及说明
       </a>
      </li>
      <li>
       <a href="http://seanlook.com/2015/05/17/nginx-install-and-config/">
        nginx服务器安装及配置文件详解
       </a>
      </li>
     </ul>
    </article>
   </div>
   <!-- Footer -->
   <footer id="footer">
    <p class="copyright">
     © Untitled. Design:
     <a href="https://html5up.net">
      HTML5 UP
     </a>
     .
    </p>
   </footer>
  </div>
  <!-- BG -->
  <div id="bg">
  </div>
  <!-- Scripts -->
  <script src="../assets/js/jquery.min.js">
  </script>
  <script src="../assets/js/browser.min.js">
  </script>
  <script src="../assets/js/breakpoints.min.js">
  </script>
  <script src="../assets/js/util.js">
  </script>
  <script src="../assets/js/main.js">
  </script>
 </body>
</html>
